from time import sleep
import RPi.GPIO as GPIO
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
 
pan = [7,11,13,33,15,35]
pwms=[]
 
 
def setServoAngle(servo, angle):
    # assert angle >=30 and angle <= 150
    GPIO.setup(servo, GPIO.OUT) # gray ==> PAN
    pwm = GPIO.PWM(servo, 50)
    pwm.start(8)
    dutyCycle = angle / 18. + 3.
    pwm.ChangeDutyCycle(dutyCycle)
    return pwm
 
if __name__ == '__main__':  
    # for i in range (30, 160, 15):
    #     setServoAngle(pan, i)
     
    # for i in range (150, 30, -15):
    #     setServoAngle(pan, i)
    
    # GPIO.setup(13,GPIO.OUT)
    # pwm_keep=GPIO.PWM(13,50)
    # pwm_keep.start(90/18.+3.)
    # sleep(5)

    pwms.append(setServoAngle(pan[2],120))
    sleep(3)

    # Exit
    for i in pwms:
        i.stop()
    GPIO.cleanup()